﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace test.converters
{
    public class BoolToVisibilityConverter : IValueConverter
    {
        // 将布尔值转换为 Visibility
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return (bool)value ? Visibility.Visible : Visibility.Collapsed; // 如果为 true 显示，false 隐藏
        }

        // 将 Visibility 转回布尔值（可选）
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is Visibility visibility)
            {
                return visibility == Visibility.Visible;
            }
            return false; // 默认返回 false
        }
    }
}
